import request from '@/utils/request'

const api_name = '/cms/article'

export default {
  // 新增文章/草稿
  createArticle(articleAdd) {
    return request({
      url: `${api_name}`,
      method: 'post',
      data: articleAdd
    })
  },
  // 更新文章/草稿
  updateArticle(articleAdd) {
    return request({
      url: `${api_name}`,
      method: 'put',
      data: articleAdd
    })
  },
  // 根据ID获取文章信息
  getArticleInfo(articleID) {
    return request({
      url: `${api_name}/get/${articleID}`,
      method: 'get'
    })
  },
  // 分页获取本人文章
  getArticleList(articlePageRequest) {
    return request({
      url: `${api_name}/list`,
      method: 'post',
      data: articlePageRequest
    })
  },
  // 获取所有文章
  getAllArticles(articlePageRequest) {
    return request({
      url: `${api_name}/all`,
      method: 'post',
      data: articlePageRequest
    })
  },
  // 根据ID删除文章
  deleteArticle(articleID) {
    return request({
      url: `${api_name}/${articleID}`,
      method: 'delete'
    })
  },
  // 从回收站回收文章至草稿箱
  recycle(articleID) {
    return request({
      url: `${api_name}/recycle/${articleID}`,
      method: 'post'
    })
  }
}
